package pacman.ml.features;

import pacman.game.Game;
import pacman.game.Constants.GHOST;

public class NonEdibleGhostDistanceThresholdFeature extends FeatureExtractor {
	public final int min_distance;
	public NonEdibleGhostDistanceThresholdFeature(float min_distance) {
		this.min_distance = (int)min_distance;
	}
	
	public float Extract(Game game) {
		int current=game.getPacmanCurrentNodeIndex();
		
		for(GHOST ghost : GHOST.values())
			if(game.getGhostEdibleTime(ghost)==0 && game.getGhostLairTime(ghost)==0)
				if(game.getShortestPathDistance(current,game.getGhostCurrentNodeIndex(ghost))<min_distance)
					return 1.0f;
		return 0.0f;
	}
}